﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0, user-scalable=no" />
<link rel="shortcut icon" href="/Images/ico/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="/css/swiper.min.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link type="text/css" rel="stylesheet" href="/layui/css/layui.css"  media="all">
<script type="text/javascript" src="/layui/layui.js" charset="utf-8"></script>
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script src="/js/swiper.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/custom.js"></script>
<script type="text/javascript" src="/js/layui-post.js"></script>
</head>
<body style="background: white">
<div class="ng-scope">
    <div class="ng-scope">
        <!--<input class="input keywords ng-pristine ng-untouched ng-valid ng-empty" onchange="kwsearch()"  onfocus="searchfocus()"  onblur="searchblur()" placeholder="搜索" type="text">-->
        <div class="list" style="margin-bottom: 50px;">
            <ul class="branch" id="branch3"></ul>
        </div>
    </div>
    <div style="width: 100%; position: fixed; text-align: center; bottom: 0px; height: 50px; line-height: 49px; font-size: 15px; font-weight: bold; background: #e7e7e7;" onclick="addAddress()">
        <img src="img/num_r.png" style="width: 20px;margin-right: 5px;" class="img-responsive num_r" alt="..." />新增收货地址
    </div>
</div>
<div class="cartempty ng-scope ng-hide">
    <h3>暂无数据</h3>
</div>
</body>
<script>
$.ajaxSetup({contentType: "application/json; charset=utf-8"});
var userInfo = $.parseJSON(sessionStorage.getItem("userInfo"));
layui.use(['layer','form','element','util'], function(){
    getAddressList();
})
function getAddressList(){
    $.post("/cateringAddress/select",JSON.stringify({userId:userInfo.userId,isDel:0}),function(res){
        $("#branch3").html("");
        if(res.data.length == 0) $(".cartempty").removeClass("ng-hide")
        else $(".cartempty").addClass("ng-hide")
        for(var i in res.data){
            $("#branch3").append(
                '<li data-id="'+res.data[i].sysId+'">' +
                '<a style="width: 100%;">' +
                '<div style="float:left;width: 20px;line-height: 60px;"><input type="radio" name="radio" id="'+res.data[i].sysId+'"></div>' +
                '<div style="float:left;">' +
                '<div class="font18">'+res.data[i].detail+'</div>' +
                '<div class="font14 coloraaa">'+res.data[i].address+'</div>' +
                '<div class="font14 coloraaa">'+res.data[i].person+' '+res.data[i].telPhone+'</div>' +
                '</div>' +
                '</a><div style="clear:both"></div>' +
                '</li>'
            )
            if(getQueryString("addressId") === res.data[i].sysId) $("#"+res.data[i].sysId).prop("checked",true);
        }
        $("#branch3").find("li").click(function(){
            $("#"+$(this).attr("data-id")).prop("checked",true);
            parent.getAddressId($(this).attr("data-id"))
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        })
    })
}
function addAddress(){
    parent.layer.open({
        type:2,
        area: ['100%', '100%'],
        title:["新增收货地址", 'text-align:center;font-size: 16px; font-weight: bold;'],
        closeBtn:1,
        btnAlign: 'c',
        offset: 'b',
        anim: 0,
        skin:'layui-layer-nobg',
        shadeClose:true,
        content:"/addresslayeradd?addressId="+$("#addressId").val(),
        scrollbar:false,
    })
}
</script>
</html>
